package main;

import org.bukkit.plugin.java.JavaPlugin;

import persistence.CConfiger;
import persistence.CHandlerManager;
import persistence.CStorageManager;
import persistence.CSubManager;
import persistence.CSubPlugin;
import persistence.ICommandHandler;

public class BAKAServerPlugin extends JavaPlugin {
	public final String PLUGIN_NAME = "RemiliaNetwork "
			+ BAKAServerPlugin.class.getName();
	public static BAKAServerPlugin instance;
	public static CConfiger config;
	public static CSubManager subs;
	public static CStorageManager storagies;
	public static CHandlerManager handlers;

	public static void LOGCONSOLE(String msg) {
		instance.getLogger().info(msg);
	}

	@Override
	public void onEnable() {
		instance = this;
		// Initial Sub Plug-ins first
		storagies = new CStorageManager();
		handlers = new CHandlerManager();
		subs = new CSubManager();

		for (CSubPlugin sub : subs.values()) {
			sub.onEnable();
			if (sub instanceof ICommandHandler) {
				handlers.AddCommandHandler((ICommandHandler) sub);
			}
			//if (sub instanceof IEventHandler) {
				//handlers.AddEventHandler(handler)
			//}
		}

		LOGCONSOLE(PLUGIN_NAME + " has been started.");
	}

	@Override
	public void onDisable() {
		for (CSubPlugin sub : subs.values()) {
			sub.onEnable();
		}
		LOGCONSOLE(PLUGIN_NAME + " has been disabled.");
	}

}
